<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\ModerationConsole;
use App\Models\House;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;

class ModerationConsoleController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {



        return Grid::make(new ModerationConsole(), function (Grid $grid) {

            //取出房源表数据
            $houseData=House::HouseData();
            dd($houseData);

            //清空redis
            //房源表数据存到redis

            $grid->column('id')->sortable();
            $grid->column('house_name','标题');
            $grid->column('house_area','小区名称');
            $grid->column('house_build_area','建筑面积');
            $grid->column('house_use_area','使用面积');
            $grid->column('house_status','审核状态')->using(['0'=>'待审核', '1'=>'审核不通过','2'=>'审核通过','3'=>'未租/售','4'=>'已租/售']);
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->equal('house_status','状态')->select(['0'=>'待审核', '1'=>'审核不通过','2'=>'审核通过','3'=>'未租/售','4'=>'已租/售']);

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new ModerationConsole(), function (Show $show) {
            $show->field('id');
            $show->field('broker_id');
            $show->field('house_name');
            $show->field('house_area');
            $show->field('house_type');
            $show->field('house_province');
            $show->field('house_city');
            $show->field('house_region');
            $show->field('house_address');
            $show->field('longitude');
            $show->field('latitude');
            $show->field('house_direction');
            $show->field('house_build_area');
            $show->field('house_use_area');
            $show->field('house_year');
            $show->field('house_floor');
            $show->field('house_room');
            $show->field('house_img');
            $show->field('house_date_type');
            $show->field('house_price_range');
            $show->field('house_config');
            $show->field('house_label');
            $show->field('house_owner');
            $show->field('house_status');
            $show->field('house_desc');
            $show->field('house_property_type');
            $show->field('is_recommend');
            $show->field('pay_money');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ModerationConsole(), function (Form $form) {
            $form->display('id');
            $form->text('broker_id');
            $form->text('house_name');
            $form->text('house_area');
            $form->text('house_type');
            $form->text('house_province');
            $form->text('house_city');
            $form->text('house_region');
            $form->text('house_address');
            $form->text('longitude');
            $form->text('latitude');
            $form->text('house_direction');
            $form->text('house_build_area');
            $form->text('house_use_area');
            $form->text('house_year');
            $form->text('house_floor');
            $form->text('house_room');
            $form->text('house_img');
            $form->text('house_date_type');
            $form->text('house_price_range');
            $form->text('house_config');
            $form->text('house_label');
            $form->text('house_owner');
            $form->select('house_status','房源状态')->options(['0'=>'待审核', '1'=>'审核不通过','2'=>'审核通过','3'=>'未租/售','4'=>'已租/售']);
            $form->text('house_desc');
            $form->text('house_property_type');
            $form->text('is_recommend');
            $form->text('pay_money');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
